import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

//changes in order to make multiple logins have been integrated, refer to EmployeeForm for changes

public class AdminForm extends JPanel{
	private static final long serialVersionUID = 1L;
	JLayeredPane aMainLay;
	private static AdminProfileForm aProf = new AdminProfileForm();
	private static AdminAttendForm aAttend = new AdminAttendForm();
	private static AdminPayrollForm aPayroll = new AdminPayrollForm();
	private static AdminReportsForm aReports = new AdminReportsForm();
	private static welcomB contenPan = new welcomB();
	
	private static JButton home;
	JButton logOut, proFile, attenD, payRoll, repOrts;

	private  ImageIcon hOme = new ImageIcon(this.getClass().getResource("images/admin/home.png"));
	private  ImageIcon lOut = new ImageIcon(this.getClass().getResource("images/logout.png"));
	private  ImageIcon pRo = new ImageIcon(this.getClass().getResource("images/admin/profile.png"));
	private  ImageIcon aTt = new ImageIcon(this.getClass().getResource("images/admin/attendance.png"));
	private  ImageIcon pAy = new ImageIcon(this.getClass().getResource("images/admin/payroll.png"));
	private  ImageIcon rEp = new ImageIcon(this.getClass().getResource("images/admin/reports.png"));
	
	public AdminForm(){
		
//		aProf = new AdminProfileForm();
//		aAttend = new AdminAttendForm();
//		aPayroll = new AdminPayrollForm();
		
		home = new JButton(hOme);
		home.setBounds(340,44,65,31);
		home.setContentAreaFilled(false);
		home.setVisible(true);
		
		logOut = new JButton(lOut);
		logOut.setBounds(735,5,63,27);
		logOut.setContentAreaFilled(false);
		logOut.setVisible(true);
		
		proFile = new JButton(pRo);
		proFile.setBounds(405,42,84,33);
		proFile.setContentAreaFilled(false);
		proFile.setVisible(true);
		
		attenD = new JButton(aTt);
		attenD.setBounds(489,42,103,33);
		attenD.setContentAreaFilled(false);
		attenD.setVisible(true);
		
		payRoll = new JButton(pAy);
		payRoll.setBounds(593,42,84,33);
		payRoll.setContentAreaFilled(false);
		payRoll.setVisible(true);
		
		repOrts = new JButton(rEp);
		repOrts.setBounds(676,42,84,33);
		repOrts.setContentAreaFilled(false);
		repOrts.setVisible(true);
		
		
		aMainLay = new JLayeredPane();
		aMainLay.setOpaque(false);
		aMainLay.setSize(806,628);
		aMainLay.add(aProf);
		aMainLay.add(contenPan);
		aMainLay.add(aAttend);
		aMainLay.add(aPayroll);
		aMainLay.add(aReports);
		aMainLay.add(home);
		aMainLay.add(proFile);
		aMainLay.add(attenD);
		aMainLay.add(payRoll);
		aMainLay.add(repOrts);
		aMainLay.add(logOut);
		aMainLay.setVisible(true);
		
		contenPan.setBounds(0, 2, 617, 437);
		
		add(aMainLay);
		setLayout(null);
		setOpaque(false);
		setSize(806,628);
		setVisible(true);
		
		goToPage(0);
		
		home.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				AdminForm.goToPage(0);
		}
		});
		
		proFile.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				AdminForm.getProfile().getPane().listUpdate();
				AdminForm.goToPage(1);
		}
		});
		
		attenD.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				//AdminForm.getAttend().getPane().attendUpdate();
				AdminForm.goToPage(2);
		}
		});
		
		payRoll.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				AdminForm.goToPage(3);
		}
		});
		
		repOrts.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				AdminForm.goToPage(4);
		}
		});
		
		logOut.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				setVisible(false);
				AdminForm.goToPage(0);
				EmployeeForm.goToPage(0);
				MainPanel.goToPage(0);
		}
		});
	}
	
	public static void goToPage(int x){
		aProf.setVisible(false);
		contenPan.setVisible(false);
		aAttend.setVisible(false);
		aPayroll.setVisible(false);
		aReports.setVisible(false);
		home.setVisible(false);
		
		switch(x){
		case 0: contenPan.setVisible(true); break;
		case 1: home.setVisible(true); aProf.setVisible(true); break;
		case 2: home.setVisible(true); aAttend.setVisible(true); break;
		case 3: home.setVisible(true); aPayroll.setVisible(true); break;
		case 4: home.setVisible(true); aReports.setVisible(true); break;
		}
	}
	
	public static AdminAttendForm getAttend(){
		return aAttend;
	}
	public static AdminProfileForm getProfile(){
		return aProf;
	}
	public static AdminPayrollForm getPayroll(){
		return aPayroll;
	}
}

class welcomB extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	JLabel contentM, greet;
	private  ImageIcon welC = new ImageIcon(this.getClass().getResource("images/header/welcome.png"));
	SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy");
	Calendar now = Calendar.getInstance();
	String welcomeStr = "<html><h3>Hello " + "Admin" + "! Today is " + dateFormat.format(now.getTime()) + 
						". </h3> <hr width=550px /> <blockquote>What would you like to do today? </blockquote> </html>";

	welcomB(){
	
		greet = new JLabel(welC);
		greet.setBounds(135, 35, 265, 40);
		greet.setVisible(true);
		
		contentM = new JLabel(welcomeStr);
		contentM.setBounds(140, 80, 550, 100);
		contentM.setVisible(true);
		contentM.setForeground(Color.BLACK);
		
		setLayout(null);
		setOpaque(false);
		setVisible(true);
		add(contentM);
		add(greet);
	}
}



